package com.bestv.search.common.service.impl;

import com.bestv.search.common.dao.EntranceDao;
import com.bestv.search.common.dataSource.DataSourceKey;
import com.bestv.search.common.model.Entrance;
import com.bestv.search.common.model.uid.UID;
import com.bestv.search.common.service.EntranceManager;

import java.util.List;

public class EntranceManagerImpl implements EntranceManager {

    private EntranceDao entranceDao;

    public EntranceDao getEntranceDao() {
        return entranceDao;
    }

    public void setEntranceDao(EntranceDao entranceDao) {
        this.entranceDao = entranceDao;
    }

    @Override
    public void deleteEntrance(DataSourceKey key, Long id) {
        entranceDao.remove(id);
    }

    @Override
    public Entrance getEntranceById(DataSourceKey key, Long id) {
        return entranceDao.getEntranceById(id);
    }

    @Override
    public List<Entrance> getEntrances(DataSourceKey key) {
        return entranceDao.getEntrances();
    }

    @Override
    public Entrance saveEntrance(DataSourceKey key, Entrance entrance) {
        entrance.setId(new Long(UID.getUID(entrance)));
        return entranceDao.saveEntrance(entrance);
    }

    @Override
    public Entrance getEntranceByUrl(DataSourceKey key, String url) {
        return entranceDao.getEntranceByUrl(url);
    }

    @Override
    public List<Entrance> getComms(DataSourceKey key, String typename) {
        return entranceDao.getComms(typename);
    }
}
